#ifndef OPENCV_CAMERA_H
#define OPENCV_CAMERA_H

#include <QObject>
#include <QImage>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/objdetect/face.hpp>
#include <opencv2/core.hpp>
#include "components/contrib/include/opencv2/face.hpp"

using namespace cv;

class opencv_camera : public QObject
{
    Q_OBJECT
public:
    explicit opencv_camera(QObject *parent = nullptr);

    bool openCameraDev(int devID);
    void closeCameraDev(void);

    QImage* getCheckFaceImg(void);

    QImage getCameraImage(void);

    void setFaceRecognizer(QString path, int mode);

    QImage getCameraImage_face(void);

    int checkPicture_face(QString path);

    bool saveCameraImage(QString path);

    bool resizeStdPicture(QString readPath, QString savePath);

    QSize getPictureSize(QString path);

    bool read_csv(const String& filename, std::vector<Mat>& images, std::vector<int>& labels, char separator = ';');

    bool createRecognizerXMLFile(QString csvPath, QString savePath, QString fileName, int mode);

signals:

private:
    VideoCapture camera;
    QImage imgCheckFace;
    Ptr<face::FaceRecognizer> myModel;

    QImage MatToQImage(const cv::Mat& mat);
};

#endif // OPENCV_CAMERA_H
